<!DOCTYPE html>

<script type="module">
  import * as Comlink from "https://unpkg.com/comlink@alpha/dist/esm/comlink.mjs";
  // import * as Comlink from "../../../dist/esm/comlink.mjs";

  let instance1, instance2;
  async function showState() {
    alert(`instance1.counter = ${await instance1.counter},
      instance2.counter = ${await instance2.counter}`);
  }

  async function init() {
    const MyClass = Comlink.wrap(new Worker("worker.js"));
    instance1 = await new MyClass();
    instance2 = await new MyClass(42);
    await showState();
    await instance1.increment();
    await instance2.increment(23);
    await showState();
  }

  init();
</script>
